package com.shisfish.library.Exe;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.shisfish.library.Timing.ArrearBook;
import com.shisfish.library.Timing.ArrearUser;
import com.shisfish.library.Timing.BookLendMessage;
import com.shisfish.library.Timing.BookLoanMessage;
import com.shisfish.library.Timing.IsLogin;
import com.shisfish.library.Timing.LoanReminding;
import com.shisfish.library.Timing.SortLend;
import com.shisfish.library.Timing.SortLoan;

public class IsOverdueExe implements ServletContextListener {

	Timer timer = null;
	
	public static final int HALF_DA11Y = 12*60*60*1000;
	
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		timer = new Timer(true); 
        //timer.schedule(new IsOverdue(), 0, HALF_DA11Y);
        //timer.schedule(new IsRemindLend(), 0, HALF_DA11Y);
        timer.schedule(new BookLendMessage(), 0, HALF_DA11Y);
        timer.schedule(new BookLoanMessage(), 0, HALF_DA11Y);
        timer.schedule(new SortLend(), 0, HALF_DA11Y);
        timer.schedule(new SortLoan(), 0, HALF_DA11Y);
        timer.schedule(new LoanReminding(), 0, HALF_DA11Y);
        timer.schedule(new IsLogin(), 0, HALF_DA11Y);
        timer.schedule(new ArrearBook(), 1000, HALF_DA11Y);
        timer.schedule(new ArrearUser(), 1000, HALF_DA11Y);
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		timer.cancel();
	}

}
